const loaderUtils = require('loader-utils')

function loader(source) {
  return `
    let style = document.createElement('style')
    style.innerHTML = ${ JSON.stringify(source) }
    document.head.appendChild(style)
  `
}


loader.pitch = function (remainingRequest) {
  return `
    const style = document.createElement('style')
    style.innerHTML = require(${ loaderUtils.stringifyRequest(this, '!!' + remainingRequest)})
    document.head.appendChild(style)
  `
}
module.exports = loader
